package render;

import geom.Geometry;

public class Camera {
	
	double[] eye, gaze, up, left;	
	double[] u,v,w;
	
	double fov, s, ratio;
	
	public Camera(double[] eye, double[] gaze, double[] up, double fov, double ratio) {
		w = Geometry.product(gaze, -1/Geometry.norm(gaze));
		
		u = Geometry.crossProduct(up, w);
		Geometry.normalize(w);
		
		v = Geometry.crossProduct(w, u);
		
		this.eye = eye;
		this.gaze = gaze;
		this.up = up;
		this.left = Geometry.crossProduct(up, gaze);
		this.ratio = ratio;
		this.fov = fov;
		
		this.s = ratio / (2*Math.tan(fov));
	}
	
	public double[] getRay(double ux, double vy) {
		double[] ray = Geometry.linearCombination(0.5*ratio*ux, u, 0.5*vy, v, -s, w);
		Geometry.normalize(ray);
		
		return ray;
	}
	
	

}
